home *** CD-ROM | disk | FTP | other *** search
/ Quick PC 61 / Quick PC 61.iso / I386 / SASETUP.MSI / F77657_user_setpassword.asp < prev    next >
Encoding:
Text File  |  2003-02-21  |  10.9 KB  |  340 lines

  1. <%@ Language=VBScript   %>
  2. <%    Option Explicit     %>
  3. <%
  4.     '------------------------------------------------------------------------- 
  5.     ' user_setpassword.asp : Set password the specified user
  6.     '
  7.     ' Copyright (c) Microsoft Corporation.  All rights reserved. 
  8.     '
  9.     ' Date            Description
  10.     ' 15-jan-01        Creation date
  11.     '-------------------------------------------------------------------------
  12. %>
  13.     <!-- #include virtual="/admin/inc_framework.asp" -->
  14. <%
  15.     '-------------------------------------------------------------------------
  16.     ' Global Variables
  17.     '-------------------------------------------------------------------------
  18.     
  19.     ' Name of this source file
  20.     Const SOURCE_FILE = "User_setpassword.asp"
  21.     
  22.     ' Flag to toggle optional tracing output
  23.     Const ENABLE_TRACING = TRUE
  24.     
  25.     Dim rc                        'framework variables
  26.     Dim page                    'framework variables
  27.     
  28.     '-------------------------------------------------------------------------
  29.     ' Global Form Variables
  30.     '-------------------------------------------------------------------------
  31.     Dim F_strFirstUserName         'selected item in OTS page     First Name
  32.     Dim F_strNewpwd                 'New password
  33.     Dim F_strConfirmpwd             'Confirm Password
  34.     
  35.     
  36.     '-------------------------------------------------------------------------
  37.     'Start of localization content
  38.     '-------------------------------------------------------------------------
  39.     Dim L_PAGETITLE_TEXT
  40.     Dim L_NEWPASSWORD_TEXT
  41.     Dim L_CONFIRMPASSWORD_TEXT
  42.  
  43.     Dim L_PASSWORDNOTMATCH_ERRORMESSAGE
  44.     Dim L_PASSWORD_COMPLEXITY_ERRORMESSAGE
  45.     Dim L_ADSI_ERRORMESSAGE
  46.     Dim L_COMPUTERNAME_ERRORMESSAGE
  47.     Dim L_USERDOSENOT_EXISTS
  48.     
  49.     Const N_PASSWORD_COMPLEXITY_ERRNO    = &H800708C5  
  50.     Const N_USERDOSENOT_EXISTS_ERRNO    = &H800708AD
  51.  
  52.  
  53.     L_PAGETITLE_TEXT                    = objLocMgr.GetString("usermsg.dll","&H40300045", varReplacementStrings)
  54.     L_NEWPASSWORD_TEXT                    = objLocMgr.GetString("usermsg.dll","&H40300046", varReplacementStrings)
  55.     L_CONFIRMPASSWORD_TEXT                = objLocMgr.GetString("usermsg.dll","&H40300047", varReplacementStrings)
  56.     L_PASSWORD_COMPLEXITY_ERRORMESSAGE    = objLocMgr.GetString("usermsg.dll","&HC0300048", varReplacementStrings)
  57.     L_ADSI_ERRORMESSAGE                    = objLocMgr.GetString("usermsg.dll","&HC0300049", varReplacementStrings)
  58.     L_PASSWORDNOTMATCH_ERRORMESSAGE     = objLocMgr.GetString("usermsg.dll","&HC030004A", varReplacementStrings)
  59.     L_COMPUTERNAME_ERRORMESSAGE            = objLocMgr.GetString("usermsg.dll","&HC030004B", varReplacementStrings)
  60.     L_USERDOSENOT_EXISTS                = objLocMgr.GetString("usermsg.dll","&H4030004C", varReplacementStrings)
  61.     '-----------------------------------------------------------------------------------
  62.     'END of localization content
  63.     '-----------------------------------------------------------------------------------
  64.     
  65.     '======================================================
  66.     ' Entry point
  67.     '======================================================
  68.     
  69.     ' Create a Property Page
  70.     rc = SA_CreatePage( L_PAGETITLE_TEXT, "", PT_PROPERTY, page )
  71.     
  72.     '
  73.     ' Serve the page
  74.     rc = SA_ShowPage( page )
  75.     
  76.     '-------------------------------------------------------------------------
  77.     'Function:                OnInitPage()
  78.     'Description:            Called to signal first time processing for this page.
  79.     '                        Use this method to do first time initialization tasks
  80.     'Input Variables:        PageIn,EventArg
  81.     'Output Variables:        PageIn,EventArg
  82.     'Returns:                True/False
  83.     'Global Variables:        None
  84.     '-------------------------------------------------------------------------    
  85.     Public Function OnInitPage(ByRef PageIn, ByRef EventArg)
  86.     
  87.         If ( ENABLE_TRACING ) Then 
  88.             Call SA_TraceOut(SOURCE_FILE, "OnInitPage")
  89.         End If
  90.         
  91.         Call OTS_GetTableSelection("", 1, F_strFirstUserName)
  92.         OnInitPage = TRUE
  93.     End Function
  94.     
  95.     '-------------------------------------------------------------------------
  96.     'Function:                OnServePropertyPage()
  97.     'Description:            Called when the page needs to be served.Use this 
  98.     '                        method to serve content
  99.     'Input Variables:        PageIn,EventArg
  100.     'Output Variables:        PageIn,EventArg
  101.     'Returns:                True/False
  102.     'Global Variables:        None
  103.     '-------------------------------------------------------------------------    
  104.     Public Function OnServePropertyPage(ByRef PageIn, ByRef EventArg)
  105.         
  106.         SA_TraceOut "TEMPLATE_PROPERTY", "OnServePropertyPage"
  107.         
  108.         ' Emit Functions required by Web Framework
  109.         Call ServeCommonJavaScript()%>
  110.  
  111.             <TABLE WIDTH=518 VALIGN=middle ALIGN=left BORDER=0 CELLSPACING=0 CELLPADDING=2 class="TasksBody">
  112.             
  113.                 <TR>
  114.                     <TD colspan=6>
  115.                     <% CheckForSecureSite %>
  116.                     </TD>
  117.                 </TR>
  118.             
  119.                 <TR>
  120.                     <TD>
  121.                       
  122.                     </TD>
  123.                 </TR>
  124.                 <TR>
  125.                     <TD NOWRAP width=25%>
  126.                         <%= L_NEWPASSWORD_TEXT %>
  127.                     </TD>
  128.                     <TD>
  129.                         <input NAME="pwdPassword" TYPE="password" SIZE="20"  VALUE="" maxlength=127>
  130.                     </TD>
  131.                 </TR>
  132.                 <TR>
  133.                     <TD NOWRAP width=25%>
  134.                         <%= L_CONFIRMPASSWORD_TEXT %>
  135.                     </TD>
  136.                     <TD>
  137.                         <input NAME="pwdConfirmPassword" TYPE="password" SIZE="20"  VALUE="" maxlength=127>
  138.                     </TD>
  139.                 </TR>
  140.  
  141.             </TABLE>
  142.         
  143.             <input NAME="hdnUserName" TYPE="hidden"  VALUE="<%=Server.HTMLEncode(F_strFirstUserName)%>">
  144.         <%
  145.         OnServePropertyPage = TRUE
  146.     End Function
  147.  
  148.     '-------------------------------------------------------------------------
  149.     'Function:                OnPostBackPage()
  150.     'Description:            Called to signal that the page has been posted-back.
  151.     'Input Variables:        PageIn,EventArg
  152.     'Output Variables:        None
  153.     'Returns:                True/False
  154.     'Global Variables:        None
  155.     '-------------------------------------------------------------------------
  156.     Public Function OnPostBackPage(ByRef PageIn, ByRef EventArg)
  157.             OnPostBackPage = TRUE
  158.     End Function
  159.  
  160.     '-------------------------------------------------------------------------
  161.     'Function:                OnSubmitPage()
  162.     'Description:            Called when the page has been submitted for processing.
  163.     '                        Use this method to process the submit request.
  164.     'Input Variables:        PageIn,EventArg
  165.     'Output Variables:        None
  166.     'Returns:                True/False
  167.     'Global Variables:        F_(*)
  168.     '-------------------------------------------------------------------------
  169.     Public Function OnSubmitPage(ByRef PageIn, ByRef EventArg)
  170.         SA_TraceOut "TEMPLATE_PROPERTY", "OnSubmitPage"
  171.         
  172.             F_strNewpwd            =    Request.Form("pwdPassword")
  173.             F_strConfirmpwd        =    Request.Form("pwdConfirmPassword")
  174.             F_strFirstUserName =    Request.Form("hdnUserName")
  175.  
  176.             OnSubmitPage= SetUpdatePassword() 
  177.     End Function
  178.     
  179.      '-------------------------------------------------------------------------
  180.     'Function:                OnClosePage()
  181.     'Description:            Called when the page is about closed.Use this method
  182.     '                        to perform clean-up processing
  183.     'Input Variables:        PageIn,EventArg
  184.     'Output Variables:        None
  185.     'Returns:                True/False
  186.     'Global Variables:        None
  187.     '-------------------------------------------------------------------------
  188.     Public Function OnClosePage(ByRef PageIn, ByRef EventArg)
  189.         SA_TraceOut "TEMPLATE_PROPERTY", "OnClosePage"
  190.         OnClosePage = TRUE
  191.     End Function
  192.  
  193.     '-------------------------------------------------------------------------
  194.     'Function name:        SetUpdatePassword
  195.     'Description:        Updating the UserPassword
  196.     'Input Variables:    None
  197.     'Output Variables:    None
  198.     'Returns:            True/False
  199.     'Global Variables:
  200.     '                    In:F_strFirstUserName    'User Name
  201.     '                    In:F_strNewpwd            'New Password
  202.     '                    In:L_ADSI_ERRORMESSAGE
  203.     '                    In:L_PASSWORDCOMPLEXITY_ERRORMESSAGE
  204.     '
  205.     ' If ADSI Error, calls SetErrMsg with the error string
  206.     ' L_ADSI_ERRORMESSAGE.
  207.     ' If Password Complexity error, calls SetErrMsg with the error string
  208.     ' L_PASSWORDCOMPLEXITY_ERRORMESSAGE.
  209.     '    True  : If Implemented properly
  210.     '     False : If Not Implemented
  211.     '--------------------------------------------------------------------------
  212.     Function SetUpdatePassword
  213.         Err.Clear
  214.         on error resume next
  215.  
  216.         Dim objUser
  217.         Dim strADSIPath
  218.         Dim strServerName
  219.         
  220.         
  221.         'Gets the ComputerName from the system
  222.          strServerName = GetComputerName()
  223.  
  224.         'sets the path to the user
  225.         strADSIPath = "WinNT://" &  strServerName & "/" & F_strFirstUserName & ",user"
  226.         
  227.         'Gets the User from the system
  228.         Set objUser = GetObject(strADSIPath)
  229.         
  230.         'Response.End
  231.         If Err.Number = N_USERDOSENOT_EXISTS_ERRNO Then 
  232.                 Call SA_ServeFailurePage(L_USERDOSENOT_EXISTS )
  233.         End if
  234.         
  235.         'ADSI error
  236.         If Err.Number <> 0 Then
  237.             SetErrMsg L_ADSI_ERRORMESSAGE
  238.             SetUpdatePassword = FALSE
  239.             Exit Function
  240.         End If
  241.        
  242.         objUser.setPassword(F_strNewpwd)
  243.         objUser.SetInfo()
  244.         
  245.         'Complexity requirements
  246.         If Err.Number = N_PASSWORD_COMPLEXITY_ERRNO  Then
  247.             SetErrMsg L_PASSWORD_COMPLEXITY_ERRORMESSAGE
  248.             SetUpdatePassword = FALSE
  249.             Exit Function
  250.         End If
  251.  
  252.         'If the creation fails any other reason
  253.         If Err.Number <> 0 Then
  254.             SetErrMsg L_ADSI_ERRORMESSAGE
  255.             SetUpdatePassword = FALSE
  256.             Exit Function
  257.         End If
  258.  
  259.         Session("Item1") = F_strFirstUserName
  260.         
  261.         SetUpdatePassword =True
  262.         Set objUser=Nothing
  263.     End Function
  264.  
  265.     '-------------------------------------------------------------------------
  266.     'Function:                ServeCommonJavaScript
  267.     'Description:            Serves in initialiging the values,setting the form
  268.     '                        data and validating the form values
  269.     'Input Variables:        None
  270.     'Output Variables:        None
  271.     'Returns:                None
  272.     'Global Variables:        L_PASSWORDNOTMATCH_ERRORMESSAGE
  273.     '-------------------------------------------------------------------------
  274.     Function ServeCommonJavaScript()
  275.     %>
  276.         <script language="JavaScript" src="<%=m_VirtualRoot%>inc_global.js">
  277.         </script>
  278.         <script language="JavaScript">
  279.         
  280.         // Init Function
  281.         function Init()
  282.         {
  283.                 document.frmTask.pwdPassword.focus();
  284.                 document.frmTask.pwdPassword.select();
  285.                 document.frmTask.action = location.href                
  286.                 EnableCancel();
  287.             
  288.             SetPageChanged(false);
  289.         }
  290.  
  291.         // ValidatePage Function
  292.         // Returns: True if the page is OK, false if error(s) exist. 
  293.         function ValidatePage()
  294.         {
  295.             //alert("ValidatePage()");
  296.             
  297.             if (document.frmTask.pwdPassword.value != document.frmTask.pwdConfirmPassword.value)
  298.                 {
  299.                     SA_DisplayErr("<%= Server.HTMLEncode(L_PASSWORDNOTMATCH_ERRORMESSAGE) %>");
  300.                     document.frmTask.pwdConfirmPassword.focus();
  301.                     document.frmTask.pwdConfirmPassword.select();
  302.                     return false;
  303.                 }
  304.             return true;
  305.         }
  306.  
  307.  
  308.         // SetData Function
  309.         // This function must be included or a javascript runtime error will occur.
  310.         function SetData()
  311.         {
  312.             //alert("SetData()");
  313.         }
  314.  
  315.         // OnTextInputChanged
  316.         // ------------------
  317.         // Sample function that is invoked whenever a text input field is modified on the page.
  318.         // See the onChange attribute in the HTML INPUT tags that follow.
  319.         //
  320.         function OnTextInputChanged(objText)
  321.         {
  322.             SetPageChanged(true);
  323.         }
  324.  
  325.         // OnRadioOptionChanged
  326.         // ------------------
  327.         // Sample function that is invoked whenever a radio input field is modified on the page.
  328.         // See the onChange attribute in the HTML INPUT tags that follow.
  329.         //
  330.         function OnRadioOptionChanged(objRadio)
  331.         {
  332.             SetPageChanged(true);
  333.         }
  334.         </script>
  335.     <%
  336.     End Function
  337.  
  338.  
  339. %>
  340.